package com.tenglong.util;

import com.tenglong.iservice.pojo.Service;

import java.util.List;

public class Count {

    public Count (){
        this.cost="0";
        this.profits="0";
        this.wage="0";
    }
    /**
     * 总工资
     */
    private  String wage;
    /**
     * 成本费
     */
    private String cost;
    /**
     * 毛利润
     */
    private String profits;

    private String authl;

    public String getAuthl() {
        return authl;
    }

    public void setAuthl(String authl) {
        this.authl = authl;
    }

    public String getWage() {
        return wage;
    }

    public void setWage(String wage) {
        this.wage = wage;
    }

    public String getCost() {
        return cost;
    }

    public void setCost(String cost) {
        this.cost = cost;
    }

    public String getProfits() {
        return profits;
    }

    public void setProfits(String profits) {
        this.profits = profits;
    }

    public static Count getCount(List<Service> list){
        Count count= new Count();
        try {
            double wa=0.0;
            double co=0.0;
            double pr=0.0;
            double au=0.0;
            for (Service se:list
                 ) {
                wa+= Double.parseDouble(se.getIncomeWage());
                co+=Double.parseDouble(se.getIncomeCost());
                pr+=Double.parseDouble(se.getIncomeProfits());
                au+=Double.parseDouble(se.getIncomeActual());
            }
            count.setWage(String.valueOf(wa));
            count.setCost(String.valueOf(co));
            count.setProfits(String.valueOf(pr));
            count.setAuthl(String.valueOf(au));
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return count;
    }
}
